Mutex Object Overview

The RTSS mutex object is a synchronization object whose state is signaled when it is not owned by any thread and not signaled when the mutex is owned by a thread. The mutex object arbitrates exclusive access to a shared resource.

Ownership

A thread owns a mutex between the exit from a wait function and the call to RtReleaseMutex. No other thread can own the mutex between these calls. If another thread calls a wait function while the mutex is owned (not signaled), the wait function will not exit until the mutex owner releases the mutex , the wait call times out, or the mutex is abandoned. A mutex is considered abandoned when the owning thread terminates. The waiter can learn how a mutex was released by examining the wait function's return value. A thread that acquires an abandoned mutex should expect an inconsistent shared resource.

If more than one thread is waiting for ownership, the thread with the highest priority gets ownership. In cases where threads with the same priority are waiting to be owners, the earliest request goes first.

Environments

RTSS mutex objects are always maintained in the RTSS environment. However, Win32 processes may create, open, and own RTSS mutex objects. The RTSS mutex name space is case-sensitive and separate from the Win32 mutex name space. If a mutex object is unnamed, then it can only be used within the creating process.